<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>MKTB15</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="../css/IDEA.css" type=text/css rel=stylesheet>
<link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/>
<script src="../js/jquery-1.6.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/languages/jquery.validationEngine-zh_CN.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css"
	href="../js/window/skin/qq/ymPrompt.css" />
<SCRIPT language=javascript src="../js/window/ymPrompt_Ex.js"
	type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="../js/window/ymPrompt_source.js"
	type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="../js/IDEA_body.js"
	type=text/javascript></SCRIPT>
	<SCRIPT language=javascript src="../js/ajax.js" type=text/javascript></SCRIPT>
<script type="text/javascript">
		jQuery(document).ready(function(){
			// binds form submission and fields to the validation engine
			jQuery("#myform").validationEngine({autoHidePrompt:true});
		});

 ymPrompt.setDefaultCfg({winAlpha:'1.0',maskAlpha:'0.1',maskAlphaColor:'#00f'});
 function openwin()
 {
	 ymPrompt.win({message:'../account/queryStationInfo.html',width:800,height:400,title:'岗位信息查询',iframe:true});
 }  
 
 function openAreaWin()
 {
	 ymPrompt.win({message:'../account/queryAreaInfo.html',width:800,height:400,title:'区域信息查询',iframe:true});
 }  
 
 var strId = new Array();
 var strName = new Array();
 var areaIds = new Array();
 var areaNames = new Array();  
 
 function setAreaValue(ids,names)
 {             	 
     var areaId='';
     var areaName ='';
     if(null != ids && 0 != ids.length)
     {
         for(var i = 0; i < ids.length; i++)
         {
             areaId+=ids[i]+",";
         }
     }
      if(null != names && 0 != names.length)
     {
         for(var j = 0; j < names.length; j++)
         {
             areaName+=names[j]+",";
         }
     }
     
     document.getElementById("areaId").value= areaId.substr(0,areaId.length-1);
     
     document.getElementById("areaName").value= areaName.substr(0,areaName.length-1);
                  
     return;
 }
 
 function saveAreaValue(areaId,areaName)
 {    
      var flag = false;
        
      if(null != areaId)
      {     
        if(null != areaIds && 0 != areaIds.length)
        {
           for(var i = 0; i < areaIds.length; i++)
           {
               if(areaIds[i] == areaId)
               {
                  flag = true;   
               }
           }          
        }
        if(!flag)
        {
            areaIds.push(areaId); 
        } 
      }
      if(null != areaName )
      {
        flag = false;
        
        if(null != areaNames && 0 != areaNames.length)
        {
            for(var j = 0; j < areaNames.length; j++)
            {
                if(areaNames[j] == areaName)
                {
                    flag = true;   
                }
            }
        }      
        if(!flag)
        {
           areaNames.push(areaName); 
        }
      
      }
    setAreaValue(areaIds,areaNames);
          
 }
 function delAreaValue(areaId,areaName)
 {      
      if(null != areaId)
      {
         if(null != areaIds && 0 != areaIds.length)
         {
             for(var i = 0; i < areaIds.length; i++)
             {
                if(areaId == areaIds[i])
                {
                    areaIds.splice(i,1);                   
                }
             }
         }       
      }
      if(null != areaName)
      {
         if(null != areaNames && 0 != areaNames.length)
         {
             for(var j = 0; j < areaNames.length; j++)
             {
                if(areaName == areaNames[j])
                {
                    areaNames.splice(j,1);
                }
             }
         }        
      }
      
    setAreaValue(areaIds,areaNames);        
 }
 
 function resetValue()
 {

 	 strId = new Array();
  	 strName = new Array();
		
 	return;
 }
 
 function setValue(strId,strName)
 {             	 
     var stationId='';	
     var stationName ='';
     if(null != strId && 0 != strId.length)
     {
         for(var i = 0; i < strId.length; i++)
         {
             stationId+=strId[i]+",";
         }
     }
      if(null != strName && 0 != strName.length)
     {
         for(var j = 0; j < strName.length; j++)
         {
             stationName+=strName[j]+",";
         }
     }
     
     
     document.getElementById("stationId").value= stationId.substr(0,stationId.length-1);
     
     document.getElementById('stationName').value= stationName.substr(0,stationName.length-1);
                  
     return;
 }
 
 function saveValue(stationId,stationName)
 {   
      var flag = false;
        
      if(null != stationId)
      {     
        if(null != strId && 0 != strId.length)
        {
           for(var i = 0; i < strId.length; i++)
           {
               if(strId[i] == stationId)
               {
                  flag = true;   
               }
           }          
        }
        if(!flag)
        {
            strId.push(stationId); 
        } 
      }
      if(null != stationName )
      {
        flag = false;
        
        if(null != strName && 0 != strName.length)
        {
            for(var j = 0; j < strName.length; j++)
            {
                if(strName[j] == stationName)
                {
                    flag = true;   
                }
            }
        }      
        if(!flag)
        {
           strName.push(stationName); 
        }
      
      }
    setValue(strId,strName);
          
 }
 function delValue(stationId,stationName)
 {      
      if(null != stationId)
      {
         if(null != strId && 0 != strId.length)
         {
             for(var i = 0; i < strId.length; i++)
             {
                if(stationId == strId[i])
                {
                    strId.splice(i,1);                   
                }
             }
         }       
      }
      if(null != stationName)
      {
         if(null != strName && 0 != strName.length)
         {
             for(var j = 0; j < strName.length; j++)
             {
                if(stationName == strName[j])
                {
                    strName.splice(j,1);
                }
             }
         }        
      }
      
    setValue(strId,strName);        
 }
 function validate(myform)
 {
    if(myform.getAttribute("accountCode").value=='')
    {
        alert('请输入账号名称!');  
        
        return false;
    }
    if(myform.getAttribute("accountPassword").value=='')
    {
        alert("请输入账号密码!");
        
        return false;
    }
    if(myform.getAttribute("password2").value=='')
    {
        alert("请输入确认密码!");
        
        return false;
    }
    if(myform.getAttribute("accountPassword").value.length < 6)
    {
        alert("密码长度小于6位!");
        
        return false;
    }
    if(myform.getAttribute("userName").value=='')
    {
        alert('请输入用户名称!');  
        
        return false;
    }
    if(myform.getAttribute("accountPassword").value != myform.getAttribute("password2").value)
    {
         alert("密码与确认密码不一致!");
         
         return false;
    }
     if(myform.getAttribute("areaId").value=='')
    {
        alert('请选择区域!');  
        
        return false;
    }
 if(myform.getAttribute("isExist").value!="0")
    {
        alert("帐号名称已存在");
        
        return false;
    }
    
 }
    function checkAccountCode(obj)
    {
    	if(obj.value!="")
    	{
    		var url = "../account/checkAccountCode.html?accountCode="+encodeURIComponent(encodeURIComponent(obj.value));
    		sendRequest1(url);
    	}
    }
  //发送请求函数
	function sendRequest1(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse1;//指定响应函数
		XMLHttpReq.send(null);  // 发送请求
	}
	// 处理返回信息函数
     function processResponse1() {
	    if (XMLHttpReq.readyState == 4) 
	    {

	        var isExist = XMLHttpReq.responseText;
	        if(isExist!="0")
	        {
	        	document.getElementById("errMsg").innerHTML="帐号名称已存在";
	        	document.getElementById("isExist").value=isExist;
	        }
	        else
	        {
	        	document.getElementById("errMsg").innerHTML="";
	        	document.getElementById("isExist").value=isExist;
	        }
        }
    }

   

</script>
<META content="MSHTML 6.00.2900.3243" name=GENERATOR>
</HEAD>
<BODY>
<form id="myform" method="POST"
	action="../account/addUserAccountInfo.html" >
<TABLE width="100%" height="100%" border=0 cellPadding=0 cellSpacing=0>
	<TBODY>
		<TR>
			<TD height="100%" bgcolor="#FFFFFF" class=right_bg>
			<table width="100%" height="5" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td></td>
				</tr>
			</table>
			<table width="100%" border="0" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td width="20">&nbsp;</td>
					<td class="text_12_title">当前位置: <a href="#" class="blue_1">首页</a>&gt;
					<a href="#">权限管理</a> &gt; <a href="#">新增帐号</a>
				</tr>
			</table>
			<table width="100%" height="10" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td></td>
				</tr>
			</table>
			<table width="98%" border="0" cellpadding="0" cellspacing="0"
						background="../images/bg_body_title.jpg" class="list_border1">
						<tr>
							<td width="10">&nbsp;</td>
							<td>
								<table border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td><img src="../images/pic_title_1.jpg" name="imgL1"
											width="8" height="24" id="imgL1"></td>
										<td valign="bottom" class="text_12_border" nowrap="nowrap"
											style="cursor: hand;" id="tdTitle1">新增帐号</td>
										<td><img src="../images/pic_title_2.jpg" name="imgR1"
											width="8" height="24" id="imgR1"></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
			<table width="98%" border="0" cellpadding="0" cellspacing="0"
				class="list_border2">
				<tr>
					<td align="center" valign="top">
					<table width="98%" height="10" border="0" cellpadding="0"
						cellspacing="0">
						<tr>
							<td></td>
						</tr>
					</table>
					<TABLE class=list_border cellSpacing=0 cellPadding=0 width="98%"
						border=0>
						<TBODY>
							<TR>
								<TD class=list_td_gray height=30>账号名称 ：</TD>
								<TD class=list_td_white_line><input name="accountCode"
									type="text" class="validate[required] input2" height="20" onchange="checkAccountCode(this)" > <span
									class="text_darkred">*</span>
									&nbsp;<span id="errMsg" class="text_darkred"></span>
									<input type="hidden" id="isExist" value="">
									</TD>
							</TR>
							<TR>
								<TD class=list_td_gray height=30>密码 ：</TD>
								<TD height=30 class=list_td_white_line><INPUT class=INPUT2
									type="password" id=entName22 name="accountPassword"><span
									class="text_darkred">* 密码长度大于等于6位</span></TD>
							</TR>
							<TR>
								<TD class=list_td_gray height=30>确认密码 ：</TD>
								<TD height=30 class=list_td_white_line><INPUT class=INPUT2
									type="password" id=entName22 name="password2"><span
									class="text_darkred">* 密码长度大于等于6位</span></TD>
							</TR>
							<TR>
								<TD class=list_td_gray width="140">用户名称 ：</TD>
								<TD class=list_td_white_line><input name="userName"
									type="text" class="INPUT2" height="20"> <span
									class="text_darkred">*</span></TD>
							</TR>
<!-- 							<TR> -->
<!-- 								<TD class=list_td_gray height=30>区域 ：</TD> -->
<!-- 								<TD class=list_td_white_line width="88%"><textarea -->
<!-- 									id="areaName" name="areaName" class="input_textarea" -->
<!-- 									readonly="true"></textarea> <INPUT class=INPUT2 type="hidden" id=areaId -->
<!-- 									name="areaId"><input type="button" name="chooseArea" -->
<!-- 									onclick="openAreaWin();" value="请选择区域"> <span -->
<!-- 									class="text_darkred">*</span></TD> -->
<!-- 							</TR> -->
							<TR>
								<TD class=list_td_gray height=30>岗位信息 ：</TD>
								<TD class=list_td_white_line width="88%"><textarea
									id="stationName" name="stationName" class="input_textarea"
									readonly="true"></textarea> <INPUT class=INPUT2 type="hidden" id=stationId
									name="stationId"><input type="button" name="chooseRole"
									onclick="openwin();" value="请选择岗位"></TD>
							</TR>
						</TBODY>
					</TABLE>
					<table width="98%" height="42" border="0" cellpadding="0"
						cellspacing="0">
						<tr>
							<td width="40%" align="center"><input name="Submit2"
								type="submit" class="button_normal" value="完  成">
							&nbsp;&nbsp; <input name="Submit3" type="button"
								class="button_normal" value="返  回"
								onclick="window.location.href='../account/queryUserAccountInfo.html'"></td>
						</tr>
					</table>
					</td>
				</tr>
			</table>
			<table width="98%" height="5" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td></td>
				</tr>
			</table>
			</TD>
		</TR>
	</TBODY>
</TABLE>
</FORM>
</BODY>
</HTML>
